﻿using GalaSoft.MvvmLight;
using Budgetsch.WP7.Model;

namespace Budgetsch.WP7.ViewModel
{
    using System;
    using System.Windows;
    using System.Windows.Input;

    using Budgetsch.WP7.Model.Live;
    using Budgetsch.WP7.Navigation;

    using GalaSoft.MvvmLight.Command;

    /// <summary>
    /// This class contains properties that the main View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {

        private readonly INavigationService _navigationService;

        public ICommand IncomeNavigationCommand { get; set; }
        public ICommand CostNavigationCommand { get; set; }
        public ICommand SavingNavigationCommand { get; set; }
        public ICommand StatisticNavigationCommand { get; set; }

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(INavigationService navigationService)
        {

            _navigationService = navigationService;


            IncomeNavigationCommand = new RelayCommand(() => this.NavigateTo("/View/IncomeView.xaml"));
            CostNavigationCommand = new RelayCommand(() => this.NavigateTo("/View/CostView.xaml"));
            SavingNavigationCommand = new RelayCommand(() => this.NavigateTo("/View/SavingView.xaml"));
            StatisticNavigationCommand = new RelayCommand(() => this.NavigateTo("/View/PublicView.xaml"));
        }

        private void NavigateTo(string uriString)
        {
            _navigationService.NavigateTo(new Uri(uriString, UriKind.Relative));
        }

        ////public override void Cleanup()
        ////{
        ////    // Clean up if needed

        ////    base.Cleanup();
        ////}
    }
}